<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <?php
        if (isset($title))
            echo "<title>$title</title>";
        else
            echo "<title>Untitled Page</title>";
        ?>
        
        <?php echo css_tag(array('common.css' => '', 'gallery.css' => '', 'jquery.ad-gallery.css' => '', 'nyroModal.css' => '', 'redmond/jquery-ui-1.8.17.custom.css' => '')); ?>
        <?php if (isset($css)) echo css_tag($css); ?>
        
        <?php echo js_tag(array('jquery-1.7.1.min.js', 'time.js', 'jquery.nyroModal.custom.js', 'jquery.ad-gallery.js', 'jquery-ui-1.8.17.custom.min.js')); ?>
        <?php if (isset($js)) echo js_tag($js); ?>
    </head>
    <body onload="getTime();">
        <?php if(isset($message) && $message!=''): ?>
            <div id="message">
                <?=$message?>
            </div>
        <?php endif; ?>
        <div id="header">
            <img src="<?php echo base_url('img/logo.png');?>" alt="logo" class="logo" />
            <div class="top-right">
                <span id="date"></span>&nbsp;<span id="clock"></span>
                <div style="text-align: right; margin-top: 3px; font-style: italic;">
                    <?php if (isset($userdata['username']))
                        echo "Welcome, {$userdata['username']}"; ?>
                </div>
            </div>
        </div>
        <?php if(!isset($userdata['username'])): ?>
        <div id="container">
            <?php if (isset($page)) include $page . '.php'; ?>
        </div>
        <?php else: ?>
        <div id="menulist">
            <?php
            if (isset($userdata['username'])) {
                if ($userdata['role'] == 'admin')
                    include 'menu.php';
                else if ($userdata['role'] == 'user')
                    include 'usermenu.php';
            }
            ?>
            <?php include 'login.php'; ?>
       </div>
       <div id="container">
           <div style="position:relative;margin: 20px 36px 26px 44px;">
               <div id="content">
                    <?php if (isset($page)) include $page . '.php'; ?>
               </div>
               <div id="shadow"></div>
           </div>
       </div>
       <?php endif; ?>
    </body>
</html>